import React from 'react'
import {HashRouter,Routes,Route} from 'react-router-dom'

import Login from '../views/Login/Login'
import NewsSandBox from '../views/NewsSandBox/NewsSandBox'

export default function IndexRouter() {
  return (
    <HashRouter>
     <Routes>
        <Route path="/login" element={<Login/>}></Route>
        {/* 如果有token的话就正常跳转，如果没有的话就跳回登录页面 */}
        <Route path='/*' element={localStorage.getItem('token')?<NewsSandBox/>:<Login/>}></Route>
     </Routes>
     </HashRouter>
  )
}
